package com.hps.demo.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hps.demo.service.IOrderService;
import com.hps.demo.vo.OrderInfoVO;
import com.hps.demo.vo.PageVO;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author heps
 * @since 2020-10-27
 */
@RestController
@RequestMapping("/order")
public class OrderController {

  @Resource
  private IOrderService orderService;

  @GetMapping("/info")
  public Page<OrderInfoVO> getOrderInfo(PageVO pageVO) {
    return orderService.getOrderInfo(pageVO);
  }

  @GetMapping("/page")
  public Page<OrderInfoVO> getPage(PageVO pageVO) {
    return orderService.getOrderPage(pageVO);
  }

  @GetMapping("/cache")
  public Page<OrderInfoVO> getCache(PageVO pageVO) {
    return orderService.getOrderPageCache(pageVO);
  }

  @GetMapping("/order-info/user-id/{userId}")
  public List<OrderInfoVO> getOrderInfoByUserId(@PathVariable("userId") Long userId) {
    return orderService.getOrderInfoByUserId(userId);
  }

  @GetMapping("/order-info-single/user-id/{userId}")
  public List<OrderInfoVO> getOrderInfoSingleByUserId(@PathVariable("userId") Long userId) {
    return orderService.getOrderInfoSingleByUserId(userId);
  }

  @GetMapping("/order-info-cache/user-id/{userId}")
  public List<OrderInfoVO> getOrderInfoCacheByUserId(@PathVariable("userId") Long userId) {
    return orderService.getOrderInfoCacheByUserId(userId);
  }
}
